/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package iddscui;

import Main.Parameters;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import plugin.SystemClassLoader;
import system.ExitTimer;
import system.Message;

/**
 *
 * @author ZeM
 */
public class iddsCUIrun implements Runnable {
 public void run() {
        ConsoleInterface();
    }

    protected void ConsoleInterface() {
        //Starting the programm


        String[] input;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        while (!Parameters.exit) { //do while there was no exit command
            try {
                String inp = in.readLine();

                if (inp != null && inp.length() > 0) {
                    //checking if QuitTimer is working
                    if (Parameters.ExitTimerIsWorking) {
                        ExitTimer.stop = true; //stop timer
                        Parameters.QuitTime = -1; //quit only by user command

                    }
                    input = inp.split(" ");
                    {
                        if (input[0].equals("exit") | input[0].equals("quit")) {//exit from program
                            Parameters.exit = true;
                        } else if (input[0].equals("help")) { //start showing help
                            if (input.length == 1) {
                                //showing help
                                new SystemClassLoader("iddsHELP.jar");
                            } else {//else error too much args
                                System.out.println(new Message("er0005").message);
                            }
                        } else if (input[0].equals("plugin")) {//plugin
                            if (input[1].equals("check")) {//checking plugin(s)
                                if (input[2].equals("all")) {//checking all plugins
                                } else {
                                    for (int i = 3; i < input.length; i++) {
                                        //check each plugin - inp[i]
                                    }
                                }
                            } else if (input[1].equals("help")) {//getting help from plugin inp[2]
                            } else if (input[1].equals("about")) {//getting information about plugin inp[2]
                            } else  System.out.println(new Message("er0005").message);


                        } else if (input[0].equals("task")) {
                            // add remove run list report
                            if (input[1].equals("add")) {
                            } else if (input[1].equals("delete")) {
                            } else if (input[1].equals("run")) {
                            } else if (input[1].equals("list")) {
                            } else if (input[1].equals("report")) {
                            } else {
                                 System.out.println(new Message("er0005").message);//error
                            }
                        } else if (input[0].equals("create")) {
                            //create task;report;keyfile
                        } else if (input[0].equals("set")) {
                            //set parameter inp[1] to inp[2]
                        }
                    }





                }
            } catch (Exception IOex) {
            }
        }


    }
}
